package cn.regexp.demo.factory;

import cn.regexp.demo.ui.ContentToolWindow;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;

/**
 * @author Regexp
 */
public class ContentToolWindowFactory implements ToolWindowFactory {

    private static final String DISPLAY_NAME = "Content";

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        ContentToolWindow contentToolWindow = new ContentToolWindow();

        ContentFactory contentFactory = ContentFactory.getInstance();

        Content content = contentFactory.createContent(contentToolWindow, DISPLAY_NAME, false);
        content.setCloseable(false);
        toolWindow.getContentManager().addContent(content);
    }

}
